home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Demos / Tools / AppMaker / Examples / pre-built AMReminder / PowerPlant / CAdd.cp < prev    next >
Encoding:
Text File  |  1994-11-03  |  5.3 KB  |  293 lines  |  [TEXT/MMCC]

  1. // CAdd.cp -- dialog methods
  2. // Created 01/01/95 12:01 PM by AppMaker
  3.  
  4. #include "CAdd.h"
  5.  
  6. #include <UReanimator.h>
  7. #include <LStream.h>
  8. #include <LStdControl.h>
  9. #include <LTabGroup.h>
  10. #include <LEditField.h>
  11. #include <LView.h>
  12. #include <LRadioGroup.h>
  13. #include <PP_Messages.h>
  14.  
  15. #define PPob_AddID    201
  16. #define RidL_AddID    201
  17.  
  18. //----------
  19. CAdd*
  20. CAdd::CreateAdd(
  21.     LCommander    *inSuperCommander)
  22. {
  23.     return ((CAdd *)LWindow::CreateWindow(PPob_AddID, inSuperCommander));
  24. }
  25.  
  26. //----------
  27. //    This is the function you register with URegistrar to create a
  28. //    CAdd from a resource
  29. CAdd*
  30. CAdd::CreateAddStream(
  31.     LStream    *inStream)
  32. {
  33.     return (new CAdd(inStream));
  34. }
  35.  
  36. //----------
  37. //    The default constructor does nothing.
  38. CAdd::CAdd()
  39. {
  40. }
  41.  
  42. //----------
  43. //    The read-from-stream constructor just reads a dialog object.
  44. CAdd::CAdd(
  45.     LStream    *inStream)
  46.         : LDialogBox(inStream)
  47. {
  48. }
  49.  
  50. //----------
  51. //    The destructor does nothing.
  52. CAdd::~CAdd()
  53. {
  54. }
  55.  
  56. //----------
  57. //    This member function gets called once the containment hierarchy that contains
  58. //    this pane has been built. It gives us a chance to get data members for
  59. //    interesting subviews, and to do other operations now that our subviews exist.
  60. void
  61. CAdd::FinishCreateSelf()
  62. {
  63.     LDialogBox::FinishCreateSelf();
  64.  
  65.     mOKButton = (LStdButton *)FindPaneByID('OK  ');
  66.     mCancelButton = (LStdButton *)FindPaneByID('Canl');
  67.     mDateField = (LEditField *)FindPaneByID('Dat2');
  68.     mTimeField = (LEditField *)FindPaneByID('Tim2');
  69.     mAmPmView = (LView *)FindPaneByID('AMPM');
  70.     mMessageField = (LEditField *)FindPaneByID('Msg ');
  71.     mDisplayIconCheck = (LStdCheckBox *)FindPaneByID('Icon');
  72.     mDisplayAlertCheck = (LStdCheckBox *)FindPaneByID('Alrt');
  73.     mPlaySoundCheck = (LStdCheckBox *)FindPaneByID('Play');
  74.     mSoundPopup = (LStdPopupMenu *)FindPaneByID('Soun');
  75.  
  76.     mAmPmGroup = new LRadioGroup();
  77.     mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(1));
  78.     mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(2));
  79.  
  80.     LTabGroup    *tabGroup = new LTabGroup(this);
  81.     mDateField->SetSuperCommander(tabGroup);    // becomes the active field
  82.     mTimeField->SetSuperCommander(tabGroup);
  83.     mMessageField->SetSuperCommander(tabGroup);
  84.  
  85.     UReanimator::LinkListenerToControls(this, this, RidL_AddID);
  86.         // the purpose is to "connect" self to whatever controls
  87.         // that we want to "listen" to
  88.  
  89. // any additional initialization for your dialog:
  90.  
  91. }
  92.  
  93. //----------
  94. void
  95. CAdd::ListenToMessage(
  96.     MessageT    inMessage,
  97.     void        *ioParam)
  98. {
  99.     switch (inMessage) {
  100.     case msg_OK:
  101.             GetSuperCommander()->ProcessCommand(cmd_Add, this);
  102.         break;
  103.  
  104.     case msg_Cancel:
  105.             DoClose();
  106.         break;
  107.  
  108.     default:
  109.         break;
  110.     }
  111. }
  112.  
  113. //----------
  114. Boolean
  115. CAdd::ObeyCommand(
  116.     CommandT    inCommand,
  117.     void        *ioParam)
  118. {
  119.     Boolean        cmdHandled = true;
  120.  
  121.     switch (inCommand) {
  122.  
  123.     // +++ Add cases here for the commands you handle
  124.     //        Remember to add same cases to FindCommandStatus below
  125.     //        to enable/disable the commands
  126.  
  127.     default:
  128.             cmdHandled = LDialogBox::ObeyCommand(inCommand, ioParam);
  129.         break;
  130.     }
  131.  
  132.     return cmdHandled;
  133. }
  134.  
  135. //----------
  136. void
  137. CAdd::FindCommandStatus(
  138.     CommandT    inCommand,
  139.     Boolean        &outEnabled,
  140.     Boolean        &outUsesMark,
  141.     Char16        &outMark,
  142.     Str255        outName)
  143. {
  144.     outUsesMark = false;
  145.  
  146.     switch (inCommand) {
  147.  
  148.     // +++ Add cases here for the commands you handle
  149.  
  150.     default:
  151.             LDialogBox::FindCommandStatus(inCommand, outEnabled,
  152.                                             outUsesMark, outMark, outName);
  153.         break;
  154.     }
  155. }
  156.  
  157. //----------
  158. Boolean
  159. CAdd::FocusDraw()
  160. {
  161.     Boolean        focused = LView::FocusDraw();
  162.  
  163.     if (focused) {
  164.         AuxWinHandle    awHndl;
  165.         CTabHandle        awCTable;
  166.         ColorSpec        contentSpec;
  167.  
  168.         GetAuxWin(GetMacPort(), &awHndl);
  169.         awCTable = (**awHndl).awCTable;
  170.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  171.         ::RGBBackColor(&contentSpec.rgb);
  172.     }
  173.  
  174.     return focused;
  175. }
  176.  
  177. //----------
  178. void
  179. CAdd::GetDateFieldString        (Str255        str)
  180. {
  181.     mDateField->GetDescriptor(str);
  182. }
  183.  
  184. //----------
  185. void
  186. CAdd::SetDateFieldString        (Str255        str)
  187. {
  188.     mDateField->SetDescriptor(str);
  189. }
  190.  
  191. //----------
  192. void
  193. CAdd::GetTimeFieldString        (Str255        str)
  194. {
  195.     mTimeField->GetDescriptor(str);
  196. }
  197.  
  198. //----------
  199. void
  200. CAdd::SetTimeFieldString        (Str255        str)
  201. {
  202.     mTimeField->SetDescriptor(str);
  203. }
  204.  
  205. //----------
  206. long
  207. CAdd::GetAmPmGroupChoice()
  208. {
  209.     return mAmPmGroup->GetCurrentRadioID();
  210. }
  211.  
  212. //----------
  213. void
  214. CAdd::SetAmPmGroupChoice        (long        choice)
  215. {
  216.     LControl    *theControl = (LControl *)mAmPmView->FindPaneByID(choice);
  217.  
  218.     if (theControl != nil) {
  219.         theControl->SetValue(Button_On);
  220.     }
  221. }
  222.  
  223. //----------
  224. void
  225. CAdd::GetMessageFieldString        (Str255        str)
  226. {
  227.     mMessageField->GetDescriptor(str);
  228. }
  229.  
  230. //----------
  231. void
  232. CAdd::SetMessageFieldString        (Str255        str)
  233. {
  234.     mMessageField->SetDescriptor(str);
  235. }
  236.  
  237. //----------
  238. Boolean
  239. CAdd::GetDisplayIconCheckChoice()
  240. {
  241.     return mDisplayIconCheck->GetValue();
  242. }
  243.  
  244. //----------
  245. void
  246. CAdd::SetDisplayIconCheckChoice        (Boolean    choice)
  247. {
  248.     mDisplayIconCheck->SetValue(choice);
  249. }
  250.  
  251. //----------
  252. Boolean
  253. CAdd::GetDisplayAlertCheckChoice()
  254. {
  255.     return mDisplayAlertCheck->GetValue();
  256. }
  257.  
  258. //----------
  259. void
  260. CAdd::SetDisplayAlertCheckChoice        (Boolean    choice)
  261. {
  262.     mDisplayAlertCheck->SetValue(choice);
  263. }
  264.  
  265. //----------
  266. Boolean
  267. CAdd::GetPlaySoundCheckChoice()
  268. {
  269.     return mPlaySoundCheck->GetValue();
  270. }
  271.  
  272. //----------
  273. void
  274. CAdd::SetPlaySoundCheckChoice        (Boolean    choice)
  275. {
  276.     mPlaySoundCheck->SetValue(choice);
  277. }
  278.  
  279. //----------
  280. short
  281. CAdd::GetSoundPopupChoice()
  282. {
  283.     return mSoundPopup->GetValue();
  284. }
  285.  
  286. //----------
  287. void
  288. CAdd::SetSoundPopupChoice        (short        choice)
  289. {
  290.     mSoundPopup->SetValue(choice);
  291. }
  292.  
  293.